DefaultIfEmpty(TSource) Method (ParallelQuery(TSource), TSource)

Task Parallel System.Threading

Returns the elements of the specified parallel sequence or the specified value in a singleton collection if the sequence is empty.

Namespace:  System.Linq
Assembly:  System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function DefaultIfEmpty(Of TSource) ( _
	source As ParallelQuery(Of TSource), _
	defaultValue As TSource _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> DefaultIfEmpty<TSource>(
	ParallelQuery<TSource> source,
	TSource defaultValue
)

Parameters

source
Type: System.Linq..::.ParallelQuery<(Of <(TSource>)>)
The sequence to return the specified value for if it is empty.
defaultValue
Type: TSource
The value to return if the sequence is empty.

Type Parameters

TSource
The type of the elements of source.

Return Value

A sequence that contains defaultValue if source is empty; otherwise, source.

Exceptions

ExceptionCondition
System..::.ArgumentNullException source is a null reference (Nothing in Visual Basic).

See Also